function setSliderImage(imgid) {

    var selid = '#' + imgid + "-SELECTOR";

    var oldid = $('#slider img:visible').attr('id');

    $('#' + oldid + '-SELECTOR').attr('src','http://4.bp.blogspot.com/-Dcs0C8aj0Uw/UfGFlpJsolI/AAAAAAAA7EU/gZ71cXrdRWI/s1600/empty_circle.png');
    
    $(selid).attr('src','http://2.bp.blogspot.com/-s_mCSyvhq3k/UfGFloeEGQI/AAAAAAAA7Ek/ioRq9RyyDRI/s1600/filled_circle.png');

    $('#' + oldid).fadeOut();

    $('#slider-text').html($('#' + imgid).attr('alt'));

    $('#' + imgid).fadeIn();
    
};

function setupSlideSelector() {

    $('#slide-selector').append('<img border="0" class="slide-selector-button" ' + 
                                'src="http://4.bp.blogspot.com/-aachTtperc8/UfGFlsxsZ0I/AAAAAAAA7Ec/lXK3aVaRt08/s1600/left_arrow.png"  ' +
                                'onclick=previousSliderImage() />');

    var count = 1;

    $("#slider img").each(function(){

        var imgid = "SLIDER-IMAGE-00" + count ;
        var selid = imgid + "-SELECTOR" ;

        $(this).attr('id',imgid);

        if ( $(this).is(':visible') ) {

            $('#slide-selector').append('<img border="0" class="slide-selector-button" src="http://2.bp.blogspot.com/-s_mCSyvhq3k/UfGFloeEGQI/AAAAAAAA7Ek/ioRq9RyyDRI/s1600/filled_circle.png" ' +
                                    'id="' + selid + '" onclick=setSliderImage("' + imgid + '") />');

            $('#slider-text').html($(this).attr('alt'));

        } else {
            $('#slide-selector').append('<img border="0" class="slide-selector-button" src="http://4.bp.blogspot.com/-Dcs0C8aj0Uw/UfGFlpJsolI/AAAAAAAA7EU/gZ71cXrdRWI/s1600/empty_circle.png" ' +
                                    'id="' + selid + '" onclick=setSliderImage("' + imgid + '") />');
        }

        count++;

    });

    $('#slide-selector').append('<img border="0" class="slide-selector-button" ' + 
                                'src="http://1.bp.blogspot.com/-L0TPpE6hSuw/UfGFl5DlEAI/AAAAAAAA7Eo/REIV05KAppU/s1600/right_arrow.png" ' +
                                'onclick=nextSliderImage() />');

};

function resizeSlider () {

    var winh = $(this).height() - 300;
    var imgh = $('#slider img:gt(0)').height();

    if ( imgh > winh ) {
      $('#slider').height(winh);
    } else {
      $('#slider').height(imgh); 
    }
    
    $('#right-container').height($('#left-container').height());

};

function nextSliderImage () {

    var oldid = $('#slider img:visible').attr('id');

    var count = parseInt(oldid.split("-").pop(),10);

    count++;

    var newid = "SLIDER-IMAGE-00" + count;

    if ( ! $('#' + newid).length ) {
        var newid = "SLIDER-IMAGE-001";
    }

    setSliderImage(newid);

};

function previousSliderImage () {

    var oldid = $('#slider img:visible').attr('id');

    var count = parseInt(oldid.split("-").pop(),10);

    count--;

    var newid = "SLIDER-IMAGE-00" + count;

    if ( ! $('#' + newid).length ) {
        var newid = "SLIDER-IMAGE-001";
    }

    setSliderImage(newid);

};

function showRecentActivity(BlogFeed) {

  var TotalPosts = BlogFeed.feed.entry.length ;

  $('#activity').html('');

  var firstPost = 1;

  var MonthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];

  for(var count=0; count < TotalPosts ; count++) {

    var post = BlogFeed.feed.entry[count];

    var pid = "pid" + count;
    var ptitle = post.title.$t;
    var pyear = post.published.$t.substring(0,4); 
    var pmonth = post.published.$t.substring(5,7);
    var pday = post.published.$t.substring(8,10);

    var plink;
    for(var LinkNum=0; LinkNum < post.link.length; LinkNum++) {
      if(post.link[LinkNum].rel == "alternate") {
        plink = post.link[LinkNum].href;
        break;
      }
    }

    var pimg = post.content.$t.match(/src=\"?(http.*?\.JPG)\"?/i).pop();

    var ptext = '<a  href="' + plink +'" target="_blank"><img src="' + pimg + '" /></a>';
    var ptext = ptext + '<a href="' + plink +'" target="_blank">' + ptitle.substring(0,28) + ' ...</a>' ;
    var ptext = ptext + '<br /><small><i>' + pday + ' ' + MonthNames[parseInt(pmonth,10) -1] + ' ' + pyear + '</i></small>';

    if ( firstPost ) {
      $('#activity').append('<div id="PID' + count + '" class="activity-entry" style="border: 0px;">' + ptext + '</div>');
      firstPost = 0;
    } else {
      $('#activity').append('<div id="PID' + count + '" class="activity-entry">' +  ptext + '</div>');
    }
  
  }

  resizeActivity();

};

function resizeActivity() {

  var maxPosts = 25;
  var maxHeight = $('#right-container').height() - 50;

  if ( $('#activity').height() > maxHeight ) {

     for( var count = maxPosts - 1 ; count >= 0 && $('#activity').height() - 40 >= maxHeight ; count-- ) {
         var postid = '#PID' + count;
         if ( $(postid).length > 0 ) {
             $(postid).hide();
         }
     }

  } else {

     for( var count = 0 ; count < maxPosts && $('#activity').height() + 40 <= maxHeight ; count++ ) {
         var postid = '#PID' + count;
         if ( $(postid).length > 0 ) {
             $(postid).show();
         }
     }

  }
 
};

